#coding:utf-8
import csv
#注释部分是写入Unicode CSV的方法，备用
# import codecs
# import cStringIO
#
# # 这个类来自官方文档
# class UnicodeWriter:
#     def __init__(self, f, dialect=csv.excel, encoding="utf-8-sig", **kwds):
#         self.queue = cStringIO.StringIO()
#         self.writer = csv.writer(self.queue, dialect=dialect, **kwds)
#         self.stream = f
#         self.encoder = codecs.getincrementalencoder(encoding)()
#     def writerow(self, row):
#         '''writerow(unicode) -> None
#         This function takes a Unicode string and encodes it to the output.
#         '''
#         self.writer.writerow([s.encode("utf-8") for s in row])
#         data = self.queue.getvalue()
#         data = data.decode("utf-8")
#         data = self.encoder.encode(data)
#         self.stream.write(data)
#         self.queue.truncate(0)
#
#     def writerows(self, rows):
#         for row in rows:
#             self.writerow(row)
#
# def list2csv(li):
#     with open(r'github_tag.csv', 'ab') as infile:
#         writer = UnicodeWriter(infile, delimiter=',')
#         writer.writerow(li)


def list2csv(li):
    with open('github_tag.csv', 'a+b') as f:
        w = csv.writer(f)
        w.writerow(li)